home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Graphics 2D / RotateString / rotateSampleMain.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  3.0 KB  |  98 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        rotateSampleMain.c
  3.  
  4.     Contains:    
  5.  
  6.     Written by: RT and BS    
  7.  
  8.     Copyright:    Copyright © 1992-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 08/2000        JM                Carbonized, non-Carbon code is commented out
  20.                                             for demonstration purposes.
  21.                 7/14/1999    KG                Updated for Metrowerks Codewarror Pro 2.1
  22.                 
  23.  
  24. */
  25. #include "CarbonPrefix.h"
  26. #include <Fonts.h>
  27. #include <Events.h>
  28. #include <Windows.h>
  29. #include <Menus.h>
  30. #include <TextEdit.h>
  31. #include <Dialogs.h>
  32.  
  33. #include "RotateString.h"
  34.  
  35. #define    NIL_POINTER            0L
  36. #define REMOVE_ALL_EVENTS    0
  37. #define VISIBLE                true
  38. #define    MOVE_TO_FRONT        (Ptr)-1
  39. #define HAS_GOAWAY            true
  40. void    main()
  41. {
  42.     WindowPtr    window1,window2;
  43.     BitMap        destMap;
  44.     Rect        windowRect;
  45.     RgnHandle    rgnHandle = NewRgn();
  46.     
  47.     /*InitGraf( &qd.thePort);
  48.     InitFonts();
  49.     InitWindows();
  50.     InitMenus();
  51.     TEInit();
  52.     InitDialogs( NIL_POINTER);*/
  53.     InitCursor();
  54.     FlushEvents( everyEvent, REMOVE_ALL_EVENTS);
  55.     
  56.     SetRect( &windowRect, 100, 100, 200, 200);
  57.     
  58.     window1 = NewWindow( NIL_POINTER, &windowRect, "\pCounter CW", VISIBLE,
  59.                 noGrowDocProc,(WindowPtr)-1, HAS_GOAWAY, NIL_POINTER);
  60.  
  61.     //SetPort(window1);
  62.     SetPortWindowPort(window1);
  63.     TextFont(4);
  64.     //TextFace(bold+italic);
  65.     TextSize(96);
  66.     
  67.     RotateString( "\pRotatey", &destMap, counterClockWise);
  68.     SizeWindow(window1,destMap.bounds.right,destMap.bounds.bottom,false);
  69.  
  70.     /*CopyBits( &destMap, &window1->portBits, &destMap.bounds,
  71.              &destMap.bounds, srcCopy, NIL_POINTER);*/
  72.     CopyBits( &destMap, GetPortBitMapForCopyBits(GetWindowPort(window1)), &destMap.bounds,
  73.              &destMap.bounds, srcCopy, NIL_POINTER);
  74.     QDFlushPortBuffer(GetWindowPort(window1), GetPortVisibleRegion(GetWindowPort(window1), rgnHandle));
  75.     
  76.     OffsetRect(&windowRect,(windowRect.right - windowRect.left ) + 40,0);
  77.     window2 = NewWindow( NIL_POINTER, &windowRect, "\pClock Wise", VISIBLE,
  78.                 noGrowDocProc,(WindowPtr) MOVE_TO_FRONT, HAS_GOAWAY, NIL_POINTER);
  79.  
  80.     //SetPort(window2);
  81.     SetPortWindowPort(window2);
  82.     TextFont(4);
  83.     //TextFace(bold+italic);
  84.     TextSize(96);
  85.     
  86.     RotateString( "\pRotate", &destMap, clockWise);
  87.     SizeWindow(window2,destMap.bounds.right,destMap.bounds.bottom,false);
  88.  
  89.     /*CopyBits( &destMap, &window2->portBits, &destMap.bounds,
  90.              &destMap.bounds, srcCopy, NIL_POINTER);*/
  91.     CopyBits( &destMap, GetPortBitMapForCopyBits(GetWindowPort(window2)), &destMap.bounds,
  92.              &destMap.bounds, srcCopy, NIL_POINTER);
  93.     QDFlushPortBuffer(GetWindowPort(window2), GetPortVisibleRegion(GetWindowPort(window2), rgnHandle));
  94.  
  95.     while( !Button());
  96.     
  97.     DisposeRgn(rgnHandle);
  98. }